package com.yanwq.sayhi.repository;

import com.yanwq.sayhi.bean.Article;
import com.yanwq.sayhi.bean.Club;
import com.yanwq.sayhi.bean.User;
import org.apache.catalina.Group;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

/**
 * 作者：yanwq。
 * 日期：2016/2/1。
 */
@Repository
public interface ArticleRepo extends CrudRepository<Article, Long> {

    int countByPublishTimeGreaterThanAndPermission(long publishTime, int permission);

    int countByPublishTimeGreaterThanAndClub(long publishTime, Club club);

    Page<Article> findByPermissionAndIdLessThan(int permission, long id, Pageable pageable);

    Page<Article> findByPermissionAndIdGreaterThan(int permission, long id, Pageable pageable);

    Page<Article> findByPermissionOrderByPublishTimeDesc(int permission, Pageable pageable);

    Page<Article> findByTypeOrderByPublishTimeDesc(int type, Pageable pageable);

    Page<Article> findByClubOrderByPublishTimeDesc(Club club, Pageable pageable);

    Page<Article> findByClubAndTypeOrderByPublishTimeDesc(Club club, int type, Pageable pageable);

    Page<Article> findByUserOrderByPublishTimeDesc(User user, Pageable pageable);

    Page<Article> findByPermissionAndTypeOrderByPublishTimeDesc(int type, int permission, Pageable pageable);
}